<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./TemplatePrincipal.xhtml">

            <ui:define name="top">
                <p:panel>
                    <p:clock mode="server" autoSync="true" pattern="HH:mm:ss dd/MM/yy" />
                </p:panel>
            </ui:define>

            <ui:define name="left">
                <h:form>
                    <p:panel>
                        <p:commandButton ajax="false" value="New Scholarship" action="ScholarshipCreateEdit" actionListener="#{scholarshipBean.prepareNew}" id="newButton">
                            <p:tooltip for="newButton" value="Add new Scholarship"/>
                        </p:commandButton>
                        <p:commandButton ajax="false" value="Back" action="PrincipalMenu" id="backBoton">
                            <p:tooltip for="backBoton" value="Back to main menu..."/>
                        </p:commandButton>
                    </p:panel>
                </h:form>

            </ui:define>

            <ui:define name="content">
                <f:view>
                    <h:form id="formScholar">
                        <br/>
                        <br/>
                        <p:panel>
                            <p:dataTable value="#{scholarshipBean.scholarshipList}" var="item">
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Scholarship Type"/>
                                    </f:facet>
                                    <h:outputText value="#{item.scholarshipTipe}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Description"/>
                                    </f:facet>
                                    <h:outputText value="#{item.description}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Edit"/>
                                    </f:facet>
                                    <center>
                                        <p:commandButton value="Edit" action="ScholarshipCreateEdit" 
                                                         actionListener="#{scholarshipBean.prepareEdit}"
                                                         id="editScholarButton" ajax="false">
                                            <f:setPropertyActionListener value="#{item}" target="#{scholarshipBean.scholarship}"/>
                                            <p:tooltip for="editScholarButton" value="Edit selected scholarship..."/>
                                        </p:commandButton>
                                    </center>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Details"/>
                                    </f:facet>
                                    <center>
                                        <p:commandButton value="See more" 
                                                         update=":formScholar:panelSC" 
                                                         onclick="dialogScholar.show();" 
                                                         icon="ui-icon-info" 
                                                         id="seeScholarButton">
                                            <p:tooltip for="seeScholarButton" value="See more details of selected scholar..."/>
                                            <f:setPropertyActionListener value="#{item}" target="#{scholarshipBean.scholarship}"/>
                                        </p:commandButton>
                                    </center>
                                </p:column>                                
                            </p:dataTable>
                            <p:dialog widgetVar="dialogScholar" modal="true" width="250" 
                                      height="200" showEffect="fade" hideEffect="explode" 
                                      resizable="false" position="600 ,150" 
                                      draggable="false">
                                <h1><h:outputText value="Details..."/></h1>
                                <h:panelGrid columns="2" id="panelSC">
                                    <p:outputLabel value="Id :"/>
                                    <p:outputLabel value="#{scholarshipBean.scholarship.id}" title="Id"/>
                                </h:panelGrid>
                            </p:dialog>

                        </p:panel>    
                    </h:form>
                </f:view>
            </ui:define>
        </ui:composition>
    </body>
</html>
